package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import butterknife.BindView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/5 15:01
 */

abstract class SimpleButterKnifeAdapterAdapter<T> extends BaseButterKnifeAdapter<T> {

  SimpleButterKnifeAdapterAdapter(BaseVolleyActivity context, ArrayList<T> objects) {
    super(context, objects);
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_search_person;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  protected void customizeView(TextView tvNameSearchPerson, TextView tvDepartmentSearchPerson,
      TextView tvThree, TextView tvFour, TextView tvFive, TextView tvSix, Button btn) {
  }

  @Override protected void initView(T item, BaseViewHolder baseHolder, int position) {
    ViewHolder holder = (ViewHolder) baseHolder;
    setText1(holder.mTvOne, item);
    setText2(holder.mTvTwo, item);
    setText3(holder.mTvThree, item);
    setText4(holder.mTvFour, item);
    setText5(holder.mTvFive, item);
    setText6(holder.mTvSix, item);
    //用于区分点击事件
    holder.mTvOne.setTag(item);
    holder.mTvTwo.setTag(item);
    holder.mTvThree.setTag(item);
    holder.mTvFour.setTag(item);
    holder.mTvFive.setTag(item);
    holder.mTvSix.setTag(item);
    holder.mBtn.setTag(item);
  }

  protected abstract void setText1(TextView tvOne, T item);

  protected abstract void setText2(TextView tvTwo, T item);

  protected void setText3(TextView tvThree, T item) {

  }

  protected void setText4(TextView tvFour, T item) {
  }

  protected void setText5(TextView tvFive, T item) {
  }

  protected void setText6(TextView tvSix, T item) {
  }

  public boolean isOnClick() {
    return false;
  }

  class ViewHolder extends BaseViewHolder {
    @BindView(R.id.tv_name_searchPerson) TextView mTvOne;
    @BindView(R.id.tv_department_searchPerson) TextView mTvTwo;
    @BindView(R.id.tv_three_searchPerson) TextView mTvThree;//默认隐藏
    @BindView(R.id.tv_four_searchPerson) TextView mTvFour;//默认隐藏
    @BindView(R.id.tv_five_searchPerson) TextView mTvFive;//默认隐藏
    @BindView(R.id.tv_six_searchPerson) TextView mTvSix;//默认隐藏
    @BindView(R.id.btn) Button mBtn;//默认隐藏

    protected ViewHolder(View view) {
      super(view);

      customizeView(mTvOne, mTvTwo, mTvThree, mTvFour, mTvFive, mTvSix, mBtn);
    }
  }
}
